#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

#define N 32
int A[N],B[N],C[N];

void* myfun(void *arg)
{
	int i;
	for(i=0 ;i<N;i++){
		C[i]+=A[i]*B[i];
	}
}

int main()
{
	int i;
	for(i=0;i<N;i++){
		A[i]=i;
		B[i]=-i;
		C[i]=0;
	}

	for(i=0;i<N;i++){
		printf("%d ", C[i]);
	}
		printf("\n");

	pthread_t id1,id2;
	pthread_create(&id1,NULL,myfun,NULL);
	pthread_create(&id2,NULL,myfun,NULL);
	pthread_join(id1,NULL);
	pthread_join(id1,NULL);

	//show result
	for(i=0;i<N;i++){
		printf("%d ", A[i]);
	}
		printf("\n");
	for(i=0;i<N;i++){
		printf("%d ", B[i]);
	}
		printf("\n");
	for(i=0;i<N;i++){
		printf("%d ", C[i]);
	}
		printf("\n");
	exit(0);
}
